import { defineComponent } from 'vue'
import type { RouteRecordRaw, RouteMeta } from 'vue-router'

declare type Recordable<T = any> = Record<string, T>

export type Component<T extends any = any> =
  | ReturnType<typeof defineComponent>
  // @ts-ignore
  | (() => Promise<typeof import('*.vue')>)
  | (() => Promise<T>)

// @ts-ignore
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  name: string
  meta: RouteMeta
  component?: Component | string
  components?: Component
  children?: AppRouteRecordRaw[]
  props?: Recordable
  fullPath?: string
}

export interface Meta {
  // 名称
  title: string
  // 忽略授权
  ignoreAuth?: boolean
  // 菜单权限
  permission?: string[]
  // 不缓存
  noKeepAlive?: boolean
  // 固定在tab上
  affix?: boolean
  // tab上的icon
  icon?: string
  // 跳转地址
  frameSrc?: string
  // 外部跳转地址
  externalLink?: string
  // 隐藏
  hidden?: boolean
}
